import 'package:flutter/material.dart';
import 'package:flutter_xyf/model/nav_btn.dart';
import 'package:flutter_xyf/pages/base/base_widget.dart';
import 'package:flutter_xyf/pages/component/app_bar/index.dart';
import 'package:flutter_xyf/pages/component/search_delete.dart';
import 'package:flutter_xyf/pages/extend/scrollbar/scroll_demo.dart';
import 'package:flutter_xyf/utils/navigator_util.dart';

import 'modal_bottom.dart';
import 'my_btn/index.dart';
import 'snack_bar.dart';

class MyComponent extends BaseWidget {
  @override
  BaseWidgetState getState() {
    return _MyComponentState();
  }
}

class _MyComponentState extends BaseWidgetState<MyComponent> {
  @override
  void initState() {
    super.initState();
    this.title = '基础组件';

    this.childInitData(contentShow: true);
    // Future.delayed(Duration(seconds: 2), () {
    //   this.title = 'fasdfa';
    //   this.hideAppbar = true;
    //   this.toggleContentShow();
    //   this.hideLoading();
    // });
  }

  @override
  Widget buildWidget(BuildContext context) {
    final List<NavBtn> dataList = [
      NavBtn('底部弹窗', ModalBottom()),
      NavBtn('搜索页面', MySearch()),
      NavBtn('提示SnackBar', SnackBarWidget()),
    ];
    return GridView.builder(
        itemCount: dataList.length,
        gridDelegate:
            SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
        itemBuilder: (_, index) {
          return Padding(
            padding: EdgeInsets.all(10),
            child: MyBtn(
                text: dataList[index].text,
                click: () {
                  NavigatorUtil.pushPageByFade(
                      context: context, targetPage: dataList[index].page);
                }),
          );
        });
  }

  @override
  queryData() {
    Future.delayed(Duration(seconds: 1), () {
      this.hideLoading();
    });
    // this.hideLoading();
    // _loadData();
  }

//   void _loadData(LoadType type) {
//   AccountService.letterList(
//     pageNo,
//     (Pager<LetterModel> pager) {
//       ///暂无数据
//       if (pager.total == 0) {
//         showLoadEmpty();
//         return;
//       }
//       pageNo = pager.currentPage;
//       if (type == LoadType.loadMore) {
//         letterModels.addAll(pager.list);
//       } else {
//         letterModels = pager.list;
//       }

//       showLoadSuccess();
//     },
//     (HttpError error) {
//       showLoadFailure(error.code, error.message);
//     },
//   );
// }

}
